import axios from '@/libs/request/axios'
// 获取普通车商数据 多条件
export const getCarDealerData = (params) => {
    return axios.request({
        url: '/apply/applyUserChannel/getCommomCarDealerByCondition',
        data:params,
        method: 'post'
    })
}

// 通过普通车商id查询基本信息
export const getCarDealerInfoById = (id,params) => {
    return axios.request({
        url: `/apply/applyUserChannel/getcommonCarDealerInfoById/${id}`,
        params:params,
        method: 'get'
    })
}

// 获取直营车商数据 多条件
export const getDirectCarDealerData = (params) => {
    return axios.request({
        url: '/apply/applyUserChannel/getDirectCarDealerListByCondition',
        data:params,
        method: 'post'
    })
}
// 根据普通车商id获取对应的渠道信息
export const getChannelInfoData = (id, params) => {
    return axios.request({
        url:`/apply/applyUserChannel/getChannelsByCardealerId/${id}`,
        params:params,
        method: 'get'
    })
}

// 添加普通车商
export const saveCarDealerData = (params) => {
    return axios.request({
        url: '/apply/applyUserChannel/addCarDealer',
        data:params,
        method: 'post'
    })
}

//编辑普通车商
export const editCarDealerData = (params) => {
    return axios.request({
        url: '/apply/applyUserChannel/editCarDealer',
        data:params,
        method: 'post'
    })
}

//禁用普通车商
export const disableCarDealerFromApply = (ids,channelId,status, params) => {
    return axios.request({
        url:`/apply/applyUserChannel/disableCarDealerFromApply/${ids}/${channelId}/${status}`,
        params:params,
        method: 'get'
    })
}

//禁用案件服务中普通车商
export const disableCarDealerFromCase = (ids,channelId, params) => {
    return axios.request({
        url:`/apply/applyUserChannel/disableCarDealerFromCase/${ids}/${channelId}`,
        params:params,
        method: 'get'
    })
}

//禁用直营车商
export const disableDirectCarDealer = (ids,channelId,status, params) => {
    return axios.request({
        url:`/apply/applyUserChannel/disableDirectCarDealerFromApply/${ids}/${channelId}/${status}`,
        params:params,
        method: 'get'
    })
}

//禁用案件服务中直营车商
export const disableDirectCarDealerFromCase = (ids,channelId, params) => {
    return axios.request({
        url:`/apply/applyUserChannel/disableDirectCarDealerFromApplyToCase/${ids}/${channelId}`,
        params:params,
        method: 'get'
    })
}

// 删除车商
export const deleteCardealer = (channelId,id, params) => {
    return axios.request({
        url:`/apply/applyUserChannel/deleteDirectCardealerByIdFromApply/${channelId}/${id}`,
        params:params,
        method: 'delete'
    })
}
// 删除普通车商
export const deleteCommonCardealerById = (id,channelId, params) => {
    return axios.request({
        url:`/apply/applyUserChannel/delCommonCarDealerFromApply/${id}/${channelId}`,
        params:params,
        method: 'get'
    })
}

// 保存直营车商基本信息
export const addChannel = (params) => {
    return axios.request({
        url: '/apply/applyUserChannel/saveDirectCarDealer',
        data:params,
        method: 'post'
    })
}

// 暂存直营车商基本信息
export const stagingSaveDirectCarDealer = (params) => {
    return axios.request({
        url: '/apply/applyUserChannel/stagingSaveDirectCarDealer',
        data:params,
        method: 'post'
    })
}

// 更新直营车商信息
export const updateChannel = (params) => {
    return axios.request({
        url: '/apply/applyUserChannel/updateDirectCarDealer',
        data:params,
        method: 'post'
    })
}

    //保存开票信息
export const savaInvoiceInfo = (params) => {
    return axios.request({
        url: '/apply/applyUserChannel/savaInvoiceInfo',
        data: params,
        method: 'post'
    })
}

/**
 *新增黑名单
 * @param obj
 * @returns {*}
 */
export function saveBlack(obj) {
    return axios.request({
        url: '/channel/black/save',
        method: 'POST',
        data: obj
    })
}

/**
 *验证是否在黑名单信息库中
 * @param obj
 * @returns {*}
 */
export function blackCleack(obj) {
    return axios.request({
        url: '/channel/black/checkBlack',
        method: 'POST',
        data: obj
    })
}

//批量修改业务员
export const bulkEditingSalesman = (salesman,ids,channelId, params) => {
    return axios.request({
        url:`/apply/applyUserChannel/bulkEditingSalesman/${salesman}/${ids}/${channelId}`,
        params:params,
        method: 'post'
    })
}

//批量修改案件服务中普通车商业务员
export const bulkEditingSalesmanFromCase = (salesman,ids,channelId, params) => {
    return axios.request({
        url:`/apply/applyUserChannel/bulkEditingSalesmanFromCase/${salesman}/${ids}/${channelId}`,
        params:params,
        method: 'get'
    })
}

//获取全部的直营车商城市经理
export const findAllCustomerManager = (params) => {
    return axios.request({
        url:`/channel/carDealer/findAllCustomerManager`,
        params:params,
        method: 'get'
    })
}

//批量修改直营车商城市经理
export const bulkEditingCustomerManagerFromApply = (params) => {
    return axios.request({
        url: '/apply/applyUserChannel/bulkEditingCustomerManagerFromApplyToChannel',
        data: params,
        method: 'post'
    })
}

//批量修改案件服务中的直营车商城市经理
export const bulkEditingCustomerManagerFromApplyToCase = (customerManager,channelId,ids,type, params) => {
    return axios.request({
        url:`/apply/applyUserChannel/bulkEditingCustomerManagerFromApplyToCase/${customerManager}/${channelId}/${ids}/${type}`,
        params:params,
        method: 'get'
    })
}

//获取全部的sp和总对总合作商
export const getAllSPChannels = (params) => {
    return axios.request({
        url:`/channel/carDealer/getAllSPChannels`,
        params:params,
        method: 'get'
    })
}

//获取全部的直营合作商
export const getAllDirectChannels = (params) => {
    return axios.request({
        url:`/channel/carDealer/getAllDirectChannels`,
        params:params,
        method: 'get'
    })
}

//保存普通车商到案件
export const saveCarDealerDataToCase = (params) => {
    return axios.request({
        url: '/apply/applyUserChannel/addCarDealerToCase',
        data:params,
        method: 'post'
    })
}

//更新普通车商状态
export const updateCommonCarDealerStatus = (params) => {
    return axios.request({
        url: '/channel/carDealer/updateCommonCarDealerStatus',
        data:params,
        method: 'post'
    })
}

//保存直营车商到案件
export const saveDirectCarDealerDataToCase = (params) => {
    return axios.request({
        url: '/channel/common/saveDirectCarDealer',
        data:params,
        method: 'post'
    })
}


/**
 *新增收款账号信息
 * @param params
 * @returns {*}
 */
export function saveAccountInfo(params) {
    return axios.request({
        url: '/apply/applyUserChannel/saveAccountInfo',
        method: 'POST',
        data: params
    })
}

/**
 * 修改收款账号信息
 * @param params
 * @returns {*}
 */
export function updateAccountInfo(params) {
    return axios.request({
        url: '/apply/applyUserChannel/updateAccountInfo',
        method: 'POST',
        data: params
    })
}

/**
 * 根据车商代码查询合作车商信息
 * @param params
 * @author tiankai
 */
export const getCarDealerListByCode = (params) => {
    return axios.request({
        url: '/channel/carDealer/getCarDealerListByCode',
        data:params,
        method: 'post'
    })
}

// 获取直营车商展区区域信息
export const getDirectCardealerAreaListData = (params) => {
    return axios.request({
        url: '/apply/applyUserChannel/getAreaListCondition',
        data: params,
        method: 'post'
    })
}

export function saveAccountInfoToCase(params) {
    return axios.request({
        url: '/channel/common/saveAccountInfoToCase',
        method: 'POST',
        data: params
    })
}

//根据直营车商id获取收款账号信息
export const getAccountInfoByChannelId = (channelId,params) => {
    return axios.request({
        url:`/apply/applyUserChannel/getAccountInfoByChannelId/${channelId}`,
        params:params,
        method: 'get'
    })
}

//改车商收款账号状态
export const changeAccountStatus = (channelId,params) => {
    return axios.request({
        url:`/apply/applyUserChannel/changeAccountStatus/${channelId}`,
        params:params,
        method: 'get'
    })
}

//根据渠道id获取所有的业务员
export const getAllSaleManByChannelId = (channelId,businessType,params) => {
    return axios.request({
        url:`/apply/applyUserChannel/getAllSaleManByChannelId/${channelId}/${businessType}`,
        params:params,
        method: 'get'
    })
}

// 通过车商id查询品牌信息
export const getCarBrandById = (id, params) => {
    return axios.request({
        url: `/apply/applyUserChannel/getMaiBrandById/${id}`,
        data: params,
        method: 'post'
    })
}

// 通过渠道id查询渠道信息
export const getChannelBaseInfo = (id, params) => {
    return axios.request({
        url: `/apply/applyUserChannel/getChannelBaseInfo/${id}`,
        data: params,
        method: 'post'
    })
}

// 获取车型库数据
export const getAllCarList = (params) => {
    return axios.request({
        url: '/apply/vehicle/getCarTree',
        method: 'POST',
        data: params,
    })
}

export const getAllCardealerName = (params) => {
    return axios.request({
        url: '/apply/applyUserChannel/getAllCardealerNameByChannelId',
        data:params,
        method: 'post'
    })
}

//验证直营车商跟合作商之间的合作关系
export const checkCooper = (params) => {
    return axios.request({
        url: '/apply/applyUserChannel/checkCooper',
        data:params,
        method: 'post'
    })
}

// 通过渠道id查询风控信息
export const getChannelRiskInfoById = (id, params) => {
    return axios.request({
        url: `/apply/applyUserChannel/getRiskById/${id}`,
        data: params,
        method: 'post'
    })
}

// 通过渠道id查询保证金信息
export const getChannelQuotaInfoById = (id, params) => {
    return axios.request({
        url: `/apply/applyUserChannel/getQuotaInfoById/${id}`,
        data: params,
        method: 'post'
    })
}

// 通过渠道id查询授权区域信息
export const getMainAreaById = (id, params) => {
    return axios.request({
        url: `/apply/applyUserChannel/getMainAreaById/${id}`,
        data: params,
        method: 'post'
    })
}

// 通过渠道id查询授权车型
export const getVehicleById = (id, params) => {
    return axios.request({
        url: `/apply/applyUserChannel/getVehicleById/${id}`,
        data: params,
        method: 'post'
    })
}

//省市树
export const getAllAddressList = (params) => {
    return axios.request({
        url: `/apply/common/getAddressTree`,
        method: 'POST',
        params: params,
    })
}

//获取收款账号信息-多条件
export const getListData = (params) => {
    return axios.request({
        url: '/apply/applyUserChannel/getAccountInfo',
        data:params,
        method: 'post'
    })
}

//删除收款账号信息
export const deleteAccount = (id, params) => {
    return axios.request({
        url: `/apply/applyUserChannel/deleteAccount/${id}`,
        method: 'DELETE',
        params: params,
    })
};

//根据渠道id获取授权
export const getAreaByChannelId = (channelId,businessType,params) => {
    return axios.request({
        url:`/apply/applyUserChannel/getAreaByChannelId/${channelId}/${businessType}`,
        params:params,
        method: 'get'
    })
}

// 获取车型库数据(异步)
export const getBrandTree = (params) => {
    return axios.request({
        url: '/apply/applyUserChannel/getBrandTree',
        method: 'POST',
        data: params,
    })
}

// 通过渠道id查询授权车型（新车）
export const getNewVehicleById = (id, params) => {
    return axios.request({
        url: `/apply/applyUserChannel/getNewVehicleById/${id}`,
        data: params,
        method: 'post'
    })
}

// 通过渠道id查询授权车型（二手车）
export const getOldVehicleById = (id, params) => {
    return axios.request({
        url: `/apply/applyUserChannel/getOldVehicleById/${id}`,
        data: params,
        method: 'post'
    })
}

// 通过渠道id查询所有可备案的业务员
export const getAllSaleMenByChannelId = (channelId, params) => {
    return axios.request({
        url: `/admin/applyUser/getAllSaleMenByChannelId/${channelId}`,
        params:params,
        method: 'get'
    })
}



